<?php include('../config.php');
include('../src/functions.php');
include('../src/langs.php');
?>

<script type="text/javascript">
$(function() {
    $('a.imgLink').lightBox();
}); 
</script>


<?php 

$groupsPath = 'content/grupy.xml';  
$gid = $_POST['gid'];
$lang = $_POST['lang'];

if ($_GET['lang']) {
    $lang = $_GET['lang'];
}

if( $gid != null ) {
    $path = "../".$PRODUCTS_PATH;
    if ( !($dp = opendir($path)) ) {
        die ( "Blad" );
    }
    
    $group = getGroup($groupsPath,$gid,$lang);
    ?>    
    
    <h1><?php echo $group->nazwa; ?> </h1>
    
    <div class="groupBeginning">
    <?php echo $group->desc; ?>   
    </div>  
        
    <div class="productsList" id="products">
    <?php
    
    while( $file = readdir($dp) ) {
        if( !is_dir($file) && substr($file, 0 , 1) != '.'
            && substr($file, 0 , 1) != '.' && strpos($file,".xml") ) {
            $xml = simplexml_load_file($path.$file);            
            
            if ( ($xml -> grupa) == $gid ) {
                $nazwa = $xml -> nazwa;
                $kod = $xml -> kod;
                $foto = $xml -> foto;
                $minifoto = $xml -> minifoto;
                $short = "";
                if($xml -> short['lang'] == $lang) {   
                    $short = $xml -> short; 
                }
            ?>
                <div class="product">
                    <div class="foto">
                    <a class="imgLink" title="<?php echo $nazwa; ?>" href="<?php echo $PRODUCTS_PATH."foto/".$foto; ?>">
                    <img src="<?php echo $PRODUCTS_PATH."thumbs/".$minifoto; ?>" alt=""/>
                    </a>
                    
                    
                    </div>
                    
                    
                    <div class="details">
                        <div class="name"><?php echo $nazwa ?></div>
    
                        <div class="short">
                        <?php echo $kod ?>               
                        </div>
    
                        <div class="short">
                        <?php echo $short ?>               
                        </div>
    
                        <div class="linkMore">
                        <a onclick="showDetails('<?php echo $file;?>','<?php echo $gid;?>', '<?php echo $lang; ?>');"><?php echo $MORE;?>&nbsp;&raquo;</a>                  
                        </div>
                    </div>

                    <div class="line">
                    <img src="<?php echo $SKIN.'/gradient_line.gif' ?>" alt=""/>
                    </div>
                </div>
            <?php      
            }  
        } 
    }
    ?>
    </div> 
     
    <?php
}
?>